
<%@ page import="net.loststone.*" %>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
    <title>PatoPay</title>
  <g:javascript library="prototype" />
</head>
<body>
  <div class="body">
    <h1><g:message code="home.body.h1" /></h1>
    <p class="help">(Si seleccionas tu comunidad, verás sus indicadores económicos,
      y podrás buscar ofertas de trabajo cercanas...)</p>
    <div id="states-list" class="list">
      <h2>| Comunidades |</h2>
      <table>
        <tbody>
        <g:each in="${states}" status="i" var="state">
          <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
            <td class="clickable"><g:link id="${state.id}" params="[state_id:state.id]">${fieldValue(bean: state, field: "name")}</g:link></td>
          </tr>
        </g:each>
        </tbody>
      </table>
    </div>
    <div id="provinces-list" class="list ${provinces ?: 'hide'}">
      <h2>| Provincias |</h2>
      <table>
        <tbody>
        <g:each in="${provinces}" status="i" var="province">
          <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
            <td class="clickable"><g:link id="${province.id}" params="[province_id:province.id]">${fieldValue(bean: province, field: "name")}</g:link></td>
          </tr>
        </g:each>
        </tbody>
      </table>
    </div>
    <div id="towns-list" class="list ${towns ?: 'hide'}">
      <h2>| Municipios |</h2>
      <table>
        <tbody>
        <g:each in="${towns}" status="i" var="town">
          <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
            <td class="clickable"><g:link id="${town.id}"  params="[town_id:town.id]">${fieldValue(bean: town, field: "name")}</g:link></td>
          </tr>
        </g:each>
        </tbody>
      </table>
    </div>

    <div id="actions-col">
      <div id="indicador-economic">
        <h2>| Indicadores económicos ${indicadors_economics?.size() > 0 ? "para " + indicadors_economics.get(0).afecta.name : ""} |</h2>
        <g:if test="${indicadors_economics?.size() > 0}">
          <table>
            <tbody>
            <g:each in="${indicadors_economics}" status="i" var="iEcon">
              <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <td class="clickable">
                  <ul>
                    <li><b>${fieldValue(bean: iEcon, field: "nom")}</b>
                      <ul>
                        <li><b><g:message code="patopay.inici.valor_econ" /></b> ${fieldValue(bean: iEcon, field: "valor")}<br>
                        <li><b><g:message code="patopay.inici.font_econ" /></b> ${fieldValue(bean: iEcon, field: "font")}<br>
                      </ul>
                  </ul>
                </td>
              </tr>
            </g:each>
            </tbody>
          </table>
          <div class="view-link">
            <g:link action="mostrar" controller="econInfo" id="${indicadors_economics.get(0).afecta.id}" params="[]">
              Ver + información | gráficas
            </g:link>
          </div>
        </g:if>
        <g:else>
          <span class="waiting-input"><g:message code="patopay.inici.sin_datos" /></span>
        </g:else>
      </div>

      <div id="search" class="list">
        <g:if test="${town}">
          <g:set var="selected_town" value="${town}" />
        </g:if>
        <g:elseif test="${province}">
          <g:set var="selected_town" value="${province}" />
        </g:elseif>
        <g:elseif test="${state}">
          <g:set var="selected_town" value="${state}" />
        </g:elseif>

        <g:form controller="job" method="get">
          <h2>| Buscar Ofertas de Trabajo ${selected_town ? "en " + selected_town.name : ""} |</h2>
          <g:if test="${selected_town && (selected_town.type == 'province' || selected_town.type == 'town')}">
            <table>
              <tbody>
                <tr class="prop">
                  <td valign="top" class="name">
                    <label for="keywords">Palabras Clave (profesión, especialidad, ...)</label>
                  </td>
                  <td valign="top" class="value">
              <g:hiddenField name="town_id" value="${selected_town.id}" />
              <g:textField name="keywords" value="informático, arquitecto, ..." />
              </td>
              </tr>
              </tbody>
            </table>
            <div class="view-link">
              <g:actionSubmit id="search-button" action="list" value="Buscar Ofertas" />
            </div>
          </g:if>
          <g:else>
            <span class="waiting-input">Debe seleccionar una provincia para iniciar la búsqueda...</span>
          </g:else>
        </g:form>
      </div>
    </div>

  </div>
</body>
</html>
